/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.quadbac.measurements;

import java.io.Serializable;

/**
 *
 * @author Steve
 */
@SuppressWarnings("serial")
public class Unit implements Serializable {

    private String unitSymbol;
    private String unitName;
    private ReversibleTransform<Double> unitTransform;

    public Unit() {
    }

       /**
     * Unit constructor
     * @param unitName Name of the measurement unit e.g. "Metres"
     * @param unitSymbol Symbol of the measurement unit e.g. "m"
     * @param unitOffset offset added to this unit to convert from the base unit - for the base unit, this should be set to 0
     * @param unitMultiplier multiplier to convert to this unit from the base unit - for the base unit, this should be set to 1
     */
    public Unit(String unitName, String unitSymbol, ReversibleTransform<Double> unitTransform){
        this();
        this.unitName = unitName;
        this.unitSymbol = unitSymbol;
        this.unitTransform = unitTransform;
    }

    /**
     * <code>toString{}</code> is overridden to return the unit name for combo boxes etc.
     * @return the unit name, followed by symbol in parentheses if present
     */
    @Override public String toString(){
        return getUnitFullName();
    }

    /**
     * Get the value of unitName
     *
     * @return the value of unitName
     */
    public String getUnitName() {
        return unitName;
    }
    /**
     * Get the value of unitSymbol
     *
     * @return the value of unitSymbol
     */
    public String getUnitSymbol() {
        return unitSymbol;
    }
    /**
     * Get the unit name. followed by symbol in parentheses if present
     *
     * @return the unit name, followed by symbol in parentheses if present
     */
    public String getUnitFullName() {
    	String s = unitName;
    	if (unitSymbol.length() != 0){
    		s = s+" ("+unitSymbol+")";
    	}
        return s;
    }

    public ReversibleTransform<Double> getUnitTransform() {
        return unitTransform;
    }
    /**
     * Set the value of unitName
     *
     * @param unitSymbol new value of unitName
     */

    public void setUnitName(String unitName) {
        this.unitName = unitName;
    }

    /**
     * Set the value of unitSymbol
     *
     * @param unitSymbol new value of unitSymbol
     */
    public void setUnitSymbol(String unitSymbol) {
        this.unitSymbol = unitSymbol;
    }

    /**
     * Set the value of unitTransform
     *
     * @param unitTransform new value of unitTransform
     */
    public void setUnitTransform(ReversibleTransform<Double> unitTransform) {
        this.unitTransform = unitTransform;
    }

}
